package org.redmaple.core.util;

import org.springframework.util.StringUtils;

public class Assert {
	
	public static void isTrue(boolean expression, String msg) {
		if (!expression) {
			throw new IllegalArgumentException(msg);
		}
	}
	
	public static void isTrue(boolean expression) {
		isTrue(expression, "[提示] 该布尔值不能为false");
	}
	
	public static void isFalse(boolean expression, String msg) {
		if (expression) {
			throw new IllegalArgumentException(msg);
		}
	}
	
	public static void isFalse(boolean expression) {
		isFalse(expression, "[提示] 该布尔值不能为true");
	}
	
	public static void isNull(Object object, String msg) {
		if (object != null) {
			throw new IllegalArgumentException(msg);
		}
	}
	
	public static void isNull(Object object) {
		isNull(object, "[提示] 该对象参数必须为空");
	}
	
	public static void notNull(Object object, String msg) {
		if (object == null) {
			throw new IllegalArgumentException(msg);
		}
	}
	
	public static void notNull(Object object) {
		notNull(object, "[提示] 该对象参数不能为空");
	}
	
	public static void hasText(String text, String msg) {
		if (!StringUtils.hasText(text)) {
			throw new IllegalArgumentException(msg);
		}
	}
	
	public static void hasText(String text) {
		hasText(text, "[提示] 该字符串参数不能为null或空字符串");
	}
}
